summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian de Bhal <julian.debhal@nokia.com>2011-05-09 15:20:33 +1000
committerJulian de Bhal <julian.debhal@nokia.com>2011-05-09 15:20:33 +1000
commitd5146a876e9087a3366e45728e6adf225f84927b (patch)
treec78096f85f31366000452de3ea13c18b526535aa
parent45c85b3385810d05946b84465cd33e98e787790f (diff)
Add Item3D translation manual tests
-rw-r--r--tests/manual/manual.pro9
-rw-r--r--tests/manual/translation/README1
-rw-r--r--tests/manual/translation/icon-l-qtquick3d.pngbin0 -> 6565 bytes
-rw-r--r--tests/manual/translation/m5-tst_translation_qml.desktop14
-rw-r--r--tests/manual/translation/main.cpp64
-rw-r--r--tests/manual/translation/qml/AxesVsVectorTestCase.qml114
-rw-r--r--tests/manual/translation/qml/TranslationTestCase.qml69
-rw-r--r--tests/manual/translation/qml/TranslationVectorTestCase.qml73
-rw-r--r--tests/manual/translation/qml/tst_translation.qml117
-rw-r--r--tests/manual/translation/translation.pro58
-rw-r--r--tests/manual/translation/tst_translation_qml.desktop8
11 files changed, 523 insertions, 4 deletions
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro
index 97ec9767..e14cf20f 100644
--- a/tests/manual/manual.pro
+++ b/tests/manual/manual.pro
@@ -1,6 +1,7 @@
TEMPLATE = subdirs
-SUBDIRS += submesh \
- rotation \
- displaymodel \
+SUBDIRS += displaymodel \
model3ds \
- scaling
+ rotation \
+ scaling \
+ submesh \
+ translation
diff --git a/tests/manual/translation/README b/tests/manual/translation/README
new file mode 100644
index 00000000..bbffedd5
--- /dev/null
+++ b/tests/manual/translation/README
@@ -0,0 +1 @@
+The "One teapot" test is ensuring that the two different ways of specifying position (x,y,z vs position) both have the same result. Two teapots are being rendered. To pass, the two teapots should be rendered in exactly the same position, so it looks like only one teapot. This test fails if the teapots are not aligned - e.g. there are two spouts, or the teapot is distorted.
diff --git a/tests/manual/translation/icon-l-qtquick3d.png b/tests/manual/translation/icon-l-qtquick3d.png
new file mode 100644
index 00000000..69deef3f
--- /dev/null
+++ b/tests/manual/translation/icon-l-qtquick3d.png
Binary files differ
diff --git a/tests/manual/translation/m5-tst_translation_qml.desktop b/tests/manual/translation/m5-tst_translation_qml.desktop
new file mode 100644
index 00000000..aaaa76eb
--- /dev/null
+++ b/tests/manual/translation/m5-tst_translation_qml.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Encoding=UTF-8
+Version=1.0
+Name=tst_translation
+Comment=Qt3D test application
+Exec=/usr/bin/tst_translation -fullscreen
+Icon=icon-l-qtquick3d
+Terminal=false
+Type=Application
+Categories=Development;
+X-HildonDesk-ShowInToolbar=true
+X-Osso-Type=application/x-executable
+X-Text-Domain=qt3d
+
diff --git a/tests/manual/translation/main.cpp b/tests/manual/translation/main.cpp
new file mode 100644
index 00000000..fee52cd1
--- /dev/null
+++ b/tests/manual/translation/main.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtQuick3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QApplication>
+#include <QtDeclarative/qdeclarativeview.h>
+#include <QtCore/qdir.h>
+
+#include "../../shared/qmlres.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QDeclarativeView view;
+ QString qml = q_get_qmldir(QLatin1String("qml/tst_translation.qml"));
+ view.setSource(QUrl::fromLocalFile(qml));
+
+ if (QApplication::arguments().contains(QLatin1String("-maximize")))
+ view.showMaximized();
+ else if (QApplication::arguments().contains(QLatin1String("-fullscreen")))
+ view.showFullScreen();
+ else
+ view.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/translation/qml/AxesVsVectorTestCase.qml b/tests/manual/translation/qml/AxesVsVectorTestCase.qml
new file mode 100644
index 00000000..1f08ab30
--- /dev/null
+++ b/tests/manual/translation/qml/AxesVsVectorTestCase.qml
@@ -0,0 +1,114 @@
+import QtQuick 1.0
+import Qt3D 1.0
+import Qt3D.Shapes 1.0
+
+Rectangle {
+ id: container
+ // Parameters for editting
+ property string text;
+ property variant translationVectorA: Qt.vector3d(1,1,1)
+ property variant translationVectorB: Qt.vector3d(1,1,1)
+ property variant camera: defaultCamera
+ property real itemX: 0
+ property real itemY: 0
+ property real itemZ: 0
+ property int animationDuration: 2000
+
+ // Default values:
+ property variant defaultCamera: Camera {eye: Qt.vector3d(0,5,30)}
+ property real defaultWidth: 220
+ property real defaultHeight: 150
+ property variant itemPosition:
+ Qt.vector3d((translationVectorB.x * animationFactor +
+ translationVectorA.x * (1.0 - animationFactor)),
+ translationVectorB.y * animationFactor +
+ translationVectorA.y * (1.0 - animationFactor),
+ translationVectorB.z * animationFactor +
+ translationVectorA.z * (1.0 - animationFactor))
+ property real animationFactor: 0.0
+
+ SequentialAnimation on animationFactor {
+ loops: Animation.Infinite
+ PropertyAnimation {
+ from: 0.0
+ to: 1.0
+ duration: animationDuration
+ }
+ }
+
+ border.width: 2
+ border.color: "black"
+ radius: 5
+ width: defaultWidth
+ height: defaultHeight
+
+ Text {
+ id: textItem
+ wrapMode: "WordWrap"
+ horizontalAlignment: "AlignHCenter"
+ text: container.text
+ anchors.left: parent.left
+ anchors.right: parent.right
+ }
+
+ Rectangle {
+ id: viewportContainer
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.margins: 1
+ anchors.topMargin: 2
+ anchors.top: textItem.bottom
+ anchors.bottom: container.bottom
+ color: "#aaccee"
+
+ Viewport {
+ id: view
+ anchors.fill: parent
+ picking: true
+ camera: container.camera
+
+ Material {
+ // Distinctive red Color
+ id: red
+ ambientColor: "#884422"
+ diffuseColor: "#EE4422"
+ specularColor: "#FF6644"
+ shininess: 200
+ }
+
+ Material {
+ // Distinctive blue Color
+ id: blue
+ ambientColor: "#224488"
+ diffuseColor: "#2244EE"
+ specularColor: "#4466FF"
+ shininess: 200
+ }
+
+ Effect {
+ id: redEffect; material: red
+ objectName: "redEffect"
+ }
+
+ Effect {
+ id: blueEffect; material: blue
+ objectName: "blueEffect"
+ }
+
+ Teapot
+ {
+ id: vectorModel
+// effect: redEffect
+ position: itemPosition
+ }
+ Teapot
+ {
+ id: axesModel
+// effect: blueEffect
+ x: itemX
+ y: itemY
+ z: itemZ
+ }
+ }
+ }
+}
diff --git a/tests/manual/translation/qml/TranslationTestCase.qml b/tests/manual/translation/qml/TranslationTestCase.qml
new file mode 100644
index 00000000..0cc9036c
--- /dev/null
+++ b/tests/manual/translation/qml/TranslationTestCase.qml
@@ -0,0 +1,69 @@
+import QtQuick 1.0
+import Qt3D 1.0
+import Qt3D.Shapes 1.0
+
+Rectangle {
+ id: container
+ // Parameters for editting
+ property string text;
+ property real itemX: 0
+ property real itemY: 0
+ property real itemZ: 0
+ property variant camera: defaultCamera
+
+ // Default values:
+ property variant defaultCamera: Camera { eye: Qt.vector3d(0,5,30) }
+ property real defaultWidth: 220
+ property real defaultHeight: 150
+ property real animationFactor: 0.0
+ property real animationDuration: 2000
+
+ SequentialAnimation on animationFactor {
+ loops: Animation.Infinite
+ PropertyAnimation {
+ from: 0.0
+ to: 1.0
+ duration: animationDuration
+ }
+ }
+
+ border.width: 2
+ border.color: "black"
+ radius: 5
+ width: defaultWidth
+ height: defaultHeight
+
+ Text {
+ id: textItem
+ wrapMode: "WordWrap"
+ horizontalAlignment: "AlignHCenter"
+ text: container.text
+ anchors.left: parent.left
+ anchors.right: parent.right
+ }
+
+ Rectangle {
+ id: viewportContainer
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.margins: 1
+ anchors.topMargin: 2
+ anchors.top: textItem.bottom
+ anchors.bottom: container.bottom
+ color: "#aaccee"
+
+ Viewport {
+ id: view
+ anchors.fill: parent
+ picking: true
+ camera: container.camera
+ Teapot
+ {
+ id: model
+ x: itemX
+ y: itemY
+ z: itemZ
+ }
+ }
+ }
+}
diff --git a/tests/manual/translation/qml/TranslationVectorTestCase.qml b/tests/manual/translation/qml/TranslationVectorTestCase.qml
new file mode 100644
index 00000000..fa40c828
--- /dev/null
+++ b/tests/manual/translation/qml/TranslationVectorTestCase.qml
@@ -0,0 +1,73 @@
+import QtQuick 1.0
+import Qt3D 1.0
+import Qt3D.Shapes 1.0
+
+Rectangle {
+ id: container
+ // Parameters for editting
+ property string text;
+ property variant translationVectorA: Qt.vector3d(1,1,1)
+ property variant translationVectorB: Qt.vector3d(1,1,1)
+ property variant camera: defaultCamera
+
+ // Default values:
+ property variant defaultCamera: Camera {eye: Qt.vector3d(0,5,30)}
+ property real defaultWidth: 220
+ property real defaultHeight: 150
+ property variant itemPosition:
+ Qt.vector3d((translationVectorB.x * animationFactor +
+ translationVectorA.x * (1.0 - animationFactor)),
+ translationVectorB.y * animationFactor +
+ translationVectorA.y * (1.0 - animationFactor),
+ translationVectorB.z * animationFactor +
+ translationVectorA.z * (1.0 - animationFactor))
+ property real animationFactor: 0.0
+ property int animationDuration: 2000
+
+ SequentialAnimation on animationFactor {
+ loops: Animation.Infinite
+ PropertyAnimation {
+ from: 0.0
+ to: 1.0
+ duration: animationDuration
+ }
+ }
+
+ border.width: 2
+ border.color: "black"
+ radius: 5
+ width: defaultWidth
+ height: defaultHeight
+
+ Text {
+ id: textItem
+ wrapMode: "WordWrap"
+ horizontalAlignment: "AlignHCenter"
+ text: container.text
+ anchors.left: parent.left
+ anchors.right: parent.right
+ }
+
+ Rectangle {
+ id: viewportContainer
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.margins: 1
+ anchors.topMargin: 2
+ anchors.top: textItem.bottom
+ anchors.bottom: container.bottom
+ color: "#aaccee"
+
+ Viewport {
+ id: view
+ anchors.fill: parent
+ picking: true
+ camera: container.camera
+ Teapot
+ {
+ id: model
+ position: itemPosition
+ }
+ }
+ }
+}
diff --git a/tests/manual/translation/qml/tst_translation.qml b/tests/manual/translation/qml/tst_translation.qml
new file mode 100644
index 00000000..be52c5dd
--- /dev/null
+++ b/tests/manual/translation/qml/tst_translation.qml
@@ -0,0 +1,117 @@
+import Qt 4.7
+import Qt3D 1.0
+import Qt3D.Shapes 1.0
+
+// QTBUG-17408
+Item {
+ id: screen
+ width: aTestCase.defaultWidth * 3
+ height: aTestCase.defaultHeight * 4
+
+ Flow {
+ anchors.fill: parent
+ TranslationVectorTestCase {
+ id: aTestCase
+ text: "X Translation\n(Left to Right)"
+ translationVectorA: Qt.vector3d(-4,1,1)
+ translationVectorB: Qt.vector3d(4,1,1)
+ }
+
+ TranslationVectorTestCase {
+ text: "Y Translation\n(Bottom to Top)"
+ translationVectorA: Qt.vector3d(1,-4,1)
+ translationVectorB: Qt.vector3d(1,4,1)
+ }
+
+ TranslationVectorTestCase {
+ text: "Z Translation\n(Back to Front)"
+ translationVectorA: Qt.vector3d(1,1,-4)
+ translationVectorB: Qt.vector3d(1,1,4)
+ }
+
+ TranslationVectorTestCase {
+ text: "-X Translation\n(Right to Left)"
+ translationVectorA: Qt.vector3d(4,1,1)
+ translationVectorB: Qt.vector3d(-4,1,1)
+ }
+
+ TranslationVectorTestCase {
+ text: "-Y Translation\n(Top to Bottom)"
+ translationVectorA: Qt.vector3d(1,4,1)
+ translationVectorB: Qt.vector3d(1,-4,1)
+ }
+
+ TranslationVectorTestCase {
+ text: "-Z Translation\n(Front to Back)"
+ translationVectorA: Qt.vector3d(1,1,4)
+ translationVectorB: Qt.vector3d(1,1,-4)
+ }
+
+ TranslationVectorTestCase {
+ text: "Sequential Translation in X,Y,Z\n(Previous 6 in order)"
+ id: sequentialTestCase
+ property real itemX:-4;
+ property real itemY:-4;
+ property real itemZ:-4;
+ itemPosition: Qt.vector3d(itemX,itemY,itemZ)
+ // itemPosition: Qt.vector3d(itemX,4,4)
+ SequentialAnimation {
+ loops: Animation.Infinite
+ running: true
+ PropertyAnimation {
+ target: sequentialTestCase; property: "itemX";
+ to: 4; duration: 1000
+ }
+ PropertyAnimation {
+ target: sequentialTestCase; property: "itemY";
+ to: 4; duration: 1000
+ }
+ PropertyAnimation {
+ target: sequentialTestCase; property: "itemZ";
+ to: 4; duration: 1000
+ }
+ PropertyAnimation {
+ target: sequentialTestCase; property: "itemX";
+ to: -4; duration: 1000
+ }
+ PropertyAnimation {
+ target: sequentialTestCase; property: "itemY";
+ to: -4; duration: 1000
+ }
+ PropertyAnimation {
+ target: sequentialTestCase; property: "itemZ";
+ to: -4; duration: 1000
+ }
+ }
+ }
+
+ TranslationTestCase {
+ text: "Translation in X,Y,Z properties\n(Smooth Animation)"
+ id: attributeTestCase
+ itemX: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 3.0);
+ itemY: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 5.0);
+ itemZ: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 7.0);
+ animationDuration: 15000
+ }
+
+ TranslationVectorTestCase {
+ text: "Translation in Qt.Vector3d(X,Y,Z)\n(Smooth Animation)"
+ id: combinedVectorTestCase
+ property real itemX: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 3.0);
+ property real itemY: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 5.0);
+ property real itemZ: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 7.0);
+ itemPosition: Qt.vector3d(itemX,itemY,itemZ)
+ animationDuration: 15000
+ }
+
+ AxesVsVectorTestCase {
+ text: "Last two overlaid\n(Should look like one teapot)"
+ id: axesVsVectorTestCase
+ itemX: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 3.0);
+ itemY: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 5.0);
+ itemZ: 4 * Math.sin(animationFactor * Math.PI * 2.0 * 7.0);
+ itemPosition: Qt.vector3d(itemX,itemY,itemZ)
+ animationDuration: 15000
+ }
+ }
+}
diff --git a/tests/manual/translation/translation.pro b/tests/manual/translation/translation.pro
new file mode 100644
index 00000000..fc5dad7b
--- /dev/null
+++ b/tests/manual/translation/translation.pro
@@ -0,0 +1,58 @@
+TEMPLATE = app
+TARGET = tst_translation
+CONFIG += qt warn_on
+
+SOURCES += main.cpp
+HEADERS += ../../shared/qmlres.h
+
+QT += declarative
+
+!package:DESTDIR = ../../../bin
+# for cleanup on Windows platforms - avoid deletion prompts
+win32 {
+ QMAKE_DEL_FILE = del /q
+ QMAKE_DEL_DIR = rmdir /s /q
+}
+
+qmlResources.files = qml
+symbian {
+ DEPLOYMENT = qmlResources
+} else {
+ macx {
+ qmlResources.path = Contents/Resources
+ QMAKE_BUNDLE_DATA += qmlResources
+ } else {
+ !package {
+ qmlResources.input = qmlResources.files
+ qmlResources.output = $$OUT_PWD/../../../bin/resources/tests/$$TARGET/qml
+ qmlResources.commands = $$QMAKE_COPY_DIR ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
+ qmlResources.CONFIG += no_link_no_clean
+ qmlResources.variable_out = POST_TARGETDEPS
+ QMAKE_EXTRA_COMPILERS += qmlResources
+ }
+ }
+}
+
+# for cleanup on Windows platforms - avoid deletion prompts
+win32 {
+ QMAKE_DEL_FILE = del /q
+ QMAKE_DEL_DIR = rmdir /s /q
+}
+
+# for make install use in packages
+distInstalls.files = qml
+distInstalls.path = $$[QT_INSTALL_DATA]/quick3d/tests/$$TARGET
+INSTALLS += distInstalls
+
+package {
+ maemo {
+ applnk.files = tst_translation_qml.desktop
+ applnk.path = /usr/share/applications
+
+ icons.files = icon-l-qtquick3d.png
+ icons.path = /usr/share/themes/base/meegotouch/icons
+ INSTALLS += icons applnk
+ }
+}
+target.path = $$[QT_INSTALL_BINS]
+INSTALLS += target
diff --git a/tests/manual/translation/tst_translation_qml.desktop b/tests/manual/translation/tst_translation_qml.desktop
new file mode 100644
index 00000000..23c5ac8d
--- /dev/null
+++ b/tests/manual/translation/tst_translation_qml.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=tst_translation
+Icon=icon-l-qtquick3d
+Exec=/usr/bin/tst_translation -fullscreen
+OnlyShowIn=X-MeeGo;
+X-MeeGo-Logical-Id=qtn_comm_appname_tst_translation_qml
+X-MeeGo-Translation-Catalog=essentials